<link href="<?php echo DOMAIN ?>/css/my-style.css" rel="stylesheet" type="text/css" />
<script>
	function edit_acount(id){
		domain = $("#domain").val();
		url = domain + '/admin/room/edit?id='+id;
		$("#formnew").load(url);
		$("#formnew").fadeIn();
	}

	function removeFormEdit(){
		$("#formnew").empty();
	}

	function delete_acount(id){
//		alert(id);
		var comfirmBox;
		domain = $("#domain").val();
		 comfirmBox = confirm("Bạn có chác chắn muốn xóa không ?");
		 if(comfirmBox == true)
		  {
			 $.ajax(
				      {
				    	  type:"POST",
						  url: domain + "/admin/room/delete",
						  data: "id=" + id,
						  datatype: "html",
						  success: function(html)
						     {
							  $("#" + id).remove();
						     }
				      }
				      );
		  }
	}
</script>
<input type="hidden" value="<?php echo DOMAIN_INDEX; ?>" id="domain">
<?php 
	if($this->success){
	?>
		<div class="notification success" >
			<span class="strong">Thao tác thành công.</span>
			<span class="close" title="Dismiss"></span>
		</div>
		<?php
	}
	
	if($this->warning){
		?>
			<div class="notification warning" >
				<span class="strong">Dữ liệu bạn nhập còn thiếu. Xin vui lòng kiểm tra lại!</span>
				<span class="close" title="Dismiss"></span>
			</div>
			<?php
		}
?>

<form method="post" class="form" action="" enctype="multipart/form-data">
      <fieldset>
        <legend>Thêm phòng học</legend>
        
        <p class='row-form'>
          <label class='title-row' for="City">Tên phòng học <span class="required">*</span>:</label>
          <input style="width:250px;" id="channel" type="text" name="name"  />
        </p>
        <p class='row-form'>
        	<input class="blue" style="margin-bottom:-10px;" type="submit" name="submit" value="Thêm phòng">
        </p>
      </fieldset>
</form>



<div id='formnew'></div>


<?php 
$list = $this->datas;
if($list){
?>


<div class="grid_9" id="dashtabs" style="min-height:400px;width:100%;margin-left:0px;">
<div class="box-header"> Quản lý phòng học.</div>
<div id="dashtabs-pages" class="box-content no-padding">

<table width="100%" cellspacing="0" cellpadding="4" border="0" class="table no-border">
	 <thead>
		<tr align="center" >
				<td width="20%" align="center"> STT </td>
	    		<td width="70%" align="center"> Phòng học </td>
	    		<td width="70%" align="center"> Sửa </td>
	    		<td width="70%" align="center"> Xóa </td>
			</tr>
		 </thead>
		<tbody>
			<?php
			$i = 1; 			
			foreach ($list as $key => $value) {
			
				echo ($key % 2 == 0)?("<tr class='' id = '".$value['id']."'>"):("<tr class='alt' id = '".$value['id']."'>");
				echo "<td align='center'>".$i."</td>";
				echo "<td align='center'>".$value['name']."</td>";
				echo "<td align='center'><img src='".DOMAIN."/images/myimg/edit.png' width=20 height=20 onclick='edit_acount(".$value['id'].")'></td>";
				echo "<td align='center'><img src='".DOMAIN."/images/myimg/delete.png' width=20 height=20 onclick='delete_acount(".$value['id'].")'></td>";
				?>
				
				<?php 
				$i++;
				echo "</tr>";
			}
			?>
	</tbody>
</table>
     

</div>
<div class="box-footer"> <span class="txt-smaller txt-light">Showing <?php echo count($list);?> results </span></div>
</div>

<?php 
}
?>